package com.vpclub;

import com.vpclub.bean.Boss;
import com.vpclub.bean.Car;
import com.vpclub.bean.Color;
import com.vpclub.config.MainConfigOfAutowired;
import com.vpclub.service.BookService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author : leimingchao
 * @date Date : 2021年06月22日 21:44
 */
public class IOCTest_Autowired {

    private AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigOfAutowired.class);

    @Test
    public void test() {

        BookService bookService = applicationContext.getBean(BookService.class);
        bookService.print();
        System.out.println("============================");
        Boss boss = applicationContext.getBean(Boss.class);
        System.out.println(boss);
        Car car = applicationContext.getBean(Car.class);
        System.out.println(car);
        Color color = applicationContext.getBean(Color.class);
        System.out.println(color);
        System.out.println(applicationContext);

        //容器关闭
        applicationContext.close();
    }
}
